<template>
  <div style="height:100%">

     <!-- 查询条件 -->
    <div class="query">
    <el-form :model="form" inline size="small">
        

        

        

        

        
        <el-form-item>
            <el-button type="primary" :icon="Search" @click="onQuery">查询</el-button>
            <el-button type="success" :icon="Search" @click="showAdd">添加</el-button>
        </el-form-item>
    </el-form>
</div>


    <!-- 列表 -->
    
<div class="list">
    <el-table :data="dataList" v-loading="conf.loading" stripe style="width: 100%;height:calc(100vh - 160px)" size="small" empty-text="无数据"
    >
        
    </el-table>
    <el-pagination :currentPage="form.pi" :page-size="form.ps" style="position: absolute; right: 30px;bottom:10px;"
        :page-sizes="[10, 20, 50, 100]" :background="false" small layout="total,sizes,prev, pager, next, jumper"
        :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</div>
    <CAdd ref="cadd" @onsaved="onQuery"></CAdd>
    <CEdit ref="cedit" @onsaved="onQuery"></CEdit>
    <CView ref="cview" @onsaved="onQuery"></CView>
    <DLGOpts ref="dlgOpts" @onsaved="onQuery"></DLGOpts>
  <DLGCnfrm ref="dlgCnfrm"  @onsaved="onQuery"></DLGCnfrm>

    
   
  </div>
</template>


<script>
import CAdd from "./dictionary_info.add"
import CEdit from "./dictionary_info.edit"
import CView from "./dictionary_info.view"
import DLGOpts from "./dictionary_info.opts.vue"
import DLGCnfrm from "./dictionary_info.cnfrm.vue"

  
export default {
   components: {
		CAdd,
    CEdit,
    CView,
    DLGOpts,
    DLGCnfrm,
    
  },
  data() {
    return {
      conf:{
        loading:false,
        progressColor: this.$theia.env.conf.progress||[]
      },
    form: {
        pi: 1,
        ps: 10,
        },
    dataList:[],
    total:0,};
  },
    created() {
      this.queryData()
    },
  methods:{
    queryData(){

      //构建查询参数
      let that = this
       //发送查询请求
      this.conf.loading = true
      this.$theia.http.get("/dictionaryinfo/query",this.form).then(res=>{
        that.conf.loading = false
        that.dataList = res.items
        that.total = res.count
        that.dataList.forEach(item => {
        });
      })
    },
    handleSizeChange(ps){
      this.form.ps = ps
      this.queryData()
    },
    handleCurrentChange(pi){
      this.form.pi = pi
      this.queryData()
    },
    onQuery(){
      this.form.pi = 1
      this.queryData()
    },
    showAdd(){
       this.$refs.cadd.show()
    },
     showView(q){ 
       this.$refs.cview.show(q)
    },
    showEdit(q){
        this.$refs.cedit.show(q)
      },
    colorful(r){
       return this.$theia.env.conf.colorful[r]
    },
     goto(url,param){
       if (!url) {
        return;
      }
      if (!url.indexOf("://")) {
        this.$router.push({ path: url, query: param });
        return;
      }
      let p = this.$theia.url.encode(param)
      window.location =`${url}?${p}`
    },
    
    



  },
};
</script>
<style>
.el-form-item {
  margin-right: 10px !important;
}
</style>